/**
 * *************************************
 * Copyright(c)2016 Dingdang Yixia 
 * All Rights Reserved.
 *
 * @File: PolymallEsApiController.java
 * @Package: com.purchase.rest
 * @Description:
 * 
 * @Version: V1.0
 * @Author: Yidong.Xiang
 * @Date: 2018年8月21日 下午2:57:11
 * 
 * *************************************
 */
package com.ddyx.rest;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSONObject;
import com.ddyx.model.request.CheckRefundStatusRequest;
import com.ddyx.model.request.DownloadProductRequest;
import com.ddyx.model.request.GetOrderRequest;
import com.ddyx.model.request.GetRefundRequest;
import com.ddyx.model.request.PolymallHttpRequest;
import com.ddyx.model.request.SendOrderRequest;
import com.ddyx.model.request.SyncStockRequest;
import com.ddyx.model.request.UpdateSellerMemoRequest;
import com.ddyx.model.response.CheckRefundStatusResponse;
import com.ddyx.model.response.DownloadProductResponse;
import com.ddyx.model.response.GetOrderResponse;
import com.ddyx.model.response.GetRefundResponse;
import com.ddyx.model.response.SendOrderResponse;
import com.ddyx.model.response.SyncStockResponse;
import com.ddyx.model.response.UpdateSellerMemoResponse;
import com.ddyx.service.DifferBusinessService;

/**
 * @ClassName: PolymallEsApiController.java
 * @Module: 菠萝派商城esAPI平台调用请求
 * @Description: 
 * 
 * @author: Yidong.Xiang
 * @date: 2018年8月21日 下午2:57:11
 * 
 */
@Controller
@RequestMapping("/esapi")
public class PolymallEsApiController {
	
	@Resource
	DifferBusinessService differBusinessService;
	/**
	 * 菠萝派商城统一调用入口
	 * @param method
	 * @param appkey
	 * @param token
	 * @param bizcontent
	 * @param sign
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value="/store/{storeno}",method=RequestMethod.POST,produces="application/json")
	public JSONObject callback(@PathVariable(value="storeno") String storeno
			,@RequestParam(value="method", required=true) String method
			,@RequestParam(value="appkey", required=true) String appkey
			,@RequestParam(value="token", required=true) String token
			,@RequestParam(value="bizcontent", required=true) String bizcontent
			,@RequestParam(value="sign", required=true) String sign
			)
	{
		PolymallHttpRequest request = new PolymallHttpRequest();
		request.setStoreno(storeno);
		request.setMethod(method);
		request.setAppkey(appkey);
		request.setToken(token);
		request.setBizcontent(bizcontent);
		request.setSign(sign);
		return differBusinessService.response(request);
	}
//	@ResponseBody
//	@RequestMapping(value="callback2",method=RequestMethod.POST,consumes="application/json",produces="application/json")
//	public JSONObject callback2(@RequestBody JSONObject request)
//	{
//		String method = request.getString("method");
//		String appkey = request.getString("appkey");
//		String token = request.getString("token");
//		String sign = request.getString("sign");
//		JSONObject bizcontent = request.getJSONObject("bizcontent");
//		return differBusinessService.response(method, appkey, token, bizcontent.toString(), sign);
//	}
//	/**
//	 * 订单下载
//	 * @param request
//	 * @return
//	 */
//	@ResponseBody
//	@RequestMapping(value="getOrder",method=RequestMethod.POST,consumes="application/json",produces="application/json")
//	public GetOrderResponse getOrder(@RequestBody GetOrderRequest request)
//	{
//		return differBusinessService.getOrder(request);
//	}
//	/**
//	 * 退款检测
//	 * @param request
//	 * @return
//	 */
//	@ResponseBody
//	@RequestMapping(value="checkRefundStatus",method=RequestMethod.POST,consumes="application/json",produces="application/json")
//	public CheckRefundStatusResponse checkRefundStatus(@RequestBody CheckRefundStatusRequest request)
//	{
//		return differBusinessService.checkRefundStatus(request);
//	}
//	/**
//	 * 订单发货
//	 * @param request
//	 * @return
//	 */
//	@ResponseBody
//	@RequestMapping(value="send",method=RequestMethod.POST,consumes="application/json",produces="application/json")
//	public SendOrderResponse send(@RequestBody SendOrderRequest request)
//	{
//		return differBusinessService.send(request);
//	}
//	/**
//	 * 修改订单备注
//	 * @param request
//	 * @return
//	 */
//	@ResponseBody
//	@RequestMapping(value="updateSellerMemo",method=RequestMethod.POST,consumes="application/json",produces="application/json")
//	public UpdateSellerMemoResponse updateSellerMemo(@RequestBody UpdateSellerMemoRequest request)
//	{
//		return differBusinessService.updateSellerMemo(request);
//	}
//	/**
//	 * 商品下载
//	 * @param request
//	 * @return
//	 */
//	@ResponseBody
//	@RequestMapping(value="downloadProduct",method=RequestMethod.POST)
//	public DownloadProductResponse downloadProduct(@RequestBody DownloadProductRequest request)
//	{
//		return differBusinessService.downloadProduct(request);
//	}
//	/**
//	 * 商品库存同步
//	 * @param request
//	 * @return
//	 */
//	@ResponseBody
//	@RequestMapping(value="syncStock",method=RequestMethod.POST,consumes="application/json",produces="application/json")
//	public SyncStockResponse syncStock(@RequestBody SyncStockRequest request)
//	{
//		return differBusinessService.syncStock(request);
//	}
//	/**
//	 * 退货退款单下载
//	 * @param request
//	 * @return
//	 */
//	@ResponseBody
//	@RequestMapping(value="getRefund",method=RequestMethod.POST,consumes="application/json",produces="application/json")
//	public GetRefundResponse getRefund(@RequestBody GetRefundRequest request)
//	{
//		return differBusinessService.getRefund(request);
//	}
}
